import { resolveAddressPromise } from "../../utils/address";

Page({
  data: {
    addressList: [
      {
        id: "001",
        name: "深圳市",
      },
      {
        id: "002",
        name: "北京市",
      },
    ],
  },

  onTap(event) {
    const { id } = event.currentTarget.dataset;
    console.log("id", id);

    // 基于 id 获取到所选择的城市
    const address = this.data.addressList.find((item) => item.id === id);

    // 触发 promiseResolve
    resolveAddressPromise(address);

    // 后退
    wx.navigateBack();
  },
});
